<!DOCTYPE html>
<html lang="zh-cn">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="description" content="">
    <meta name="author" content="">
    <link rel="icon" href="../../favicon.ico">

    <title>音乐分享管理系统</title>

    <!-- Bootstrap core CSS -->
    <link href="assets/css/bootstrap.min.css" rel="stylesheet">

    <!-- Custom styles for this template -->
    <link href="assets/css/offcanvas.css" rel="stylesheet">
    <link href="assets/css/style.css" rel="stylesheet">
    <!-- Just for debugging purposes. Don't actually copy these 2 lines! -->
    <!--[if lt IE 9]>
    <script src="assets/js/ie8-responsive-file-warning.js"></script><![endif]-->
    <script src="assets/js/ie-emulation-modes-warning.js"></script>

    <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
    <!--[if lt IE 9]>
    <script src="http://cdn.bootcss.com/html5shiv/3.7.2/html5shiv.min.js"></script>
    <script src="http://cdn.bootcss.com/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
</head>

<body>
<?php 
require_once('tpl/head.php');
 ?>
<nav class="navbar navbar-fixed-top navbar-inverse">
  <div class="container-fluid">
    <!-- Brand and toggle get grouped for better mobile display -->
    <div class="navbar-header">
      <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
        <span class="sr-only">Toggle navigation</span>
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
      </button>
     
    </div>

    <!-- Collect the nav links, forms, and other content for toggling -->
    <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
    <ul class="nav navbar-nav">


       
       <ul class="nav navbar-nav">
        <li><a href="index.php">首页</a></li>
        <?php

          foreach ($data['musics11'] as $row)
        {
        ?>
        <li><a href="index.php?c=index&m=lists&tid=<?php
        echo $row["tid"];
        ?>
        "><?php
        echo $row["typename"];
        ?>
        </a></li>
        <?php
          }
        ?>
        </ul>
    </ul>

        <form action="search.php"class="navbar-form navbar-left" role="search" >
        <div class="form-group">
 
        <input type="text" class="form-control" name="musicname" placeholder="Search">
        </div>

        <button type="submit" class="btn btn-default">搜索</button>
        </form>

        <ul class="nav navbar-nav navbar-right">
        <li class="active"><a href="">欢迎<?php
        session_start();
        if(isset($_SESSION["user"]))
        echo " ".$_SESSION["user"]." ";
        else{

        echo "您";
        }
        ?>访问本网站</a>
        </li>

        <?php
        //登录成功才显示
        if(isset($_SESSION["user"]))
        {
        ?>
        <li><a href="logout.php">注销</a></li>
        <li class="dropdown">
        <a
        href="#"
        class="dropdown-toggle"
        data-toggle="dropdown"
        role="button"
        aria-haspopup="true" aria-expanded="false">个人中心  <span class="caret"></span></a>
        <ul class="dropdown-menu">
        <li><a href="#" data-toggle="modal" data-target="#changePassword">修改个人密
        码</a></li>
        <li><a href="#" data-toggle="modal"  data-target="#changeInfor">修改个 人信息
        </a></li>
        <li><a href="myCommentList.php" >我的评价</a></li>
        </ul>
        </li>
        
        <?php
        }else{
        ?>
   
        <li><a href="#" data-toggle="modal" data-target="#login">登录</a></li>
        <li><a href="#" data-toggle="modal" data-target="#reg">注册</a></li>
        <?php
        }
        ?>
        </ul>

          
      
    
     
    </div><!-- /.navbar-collapse -->
  </div><!-- /.container-fluid -->
</nav>

<!-- /.navbar -->



<?php
require_once('tpl/head.php');

session_start();
//类型 id是通过  GET方法提交的
//根据类型 mid从数据库中查询某个特定视频信息
$mid = $_GET['mid'];
$sql="select * from musics where mid=$mid";
//echo $sql;
$result = mysql_query($sql) or die('查询 1失败！'.mysql_error());
$row = mysql_fetch_assoc($result);
//取得留言分页记录
//获取指定的页码
//判断是否指定第几页，如果没有指定，则显示第 1页。
if(!isset($_GET["page"]))
$page=1;
else{
$page=$_GET["page"];
}
//获取总行数，用于计算分几页显示
$sql0="select * from comments where mid=$mid";
$result0 = mysql_query($sql0);
$totalrows = mysql_num_rows($result0);
//定义每页显示的行数
$rowsperpage =5;
//计算从表中第几行开始输出
$start = ($page-1) * $rowsperpage;
//查询用户，从第$start行开始，共查询$rowsperpage行。
$sql0.= " limit {$start}, {$rowsperpage}";
// echo $sql0.'<br/>';
//执行 sql语句
$result0= mysql_query($sql0) or die('查询 2失败！'.mysql_error());
//更新点击量
$hit=$row["hittimes"]+1;
$sql2="update musics set hittimes=$hit where mid=$mid";
mysql_query($sql2) or die('查询 3失败！'.mysql_error());
 
?>

<div class="container">

    <div class="row row-offcanvas row-offcanvas-right">

        <div class="col-xs-12 col-sm-12">


            <div class="row box">
                <!-- （1）显示视频海报图片，标题和总评分的代码： -->
                <div class="col-md-4 text-center">
                <img src="upload/<?php echo $row["pic"];?> " width="200" height="250">
                <!--点击标题显示新窗口中的视频-->
                <div class="theme-buy">
                <a class="theme-login" href="javascript:;">
                <h3 class="brand-name" title="点击这里可在线播放~"><?php echo $row["musicname"];
                ?><img src="assets/images/play.png" width="30px" height="30px">
                </h3></a>
                </div>
                <div class="theme-popover">
                <div class="theme-poptit">
                <a href="javascript:;" title="关闭" class="close">×</a>
                <h4><?php echo $row["musicname"];?> </h4>
                </div>
                <div>
                <music id="mymusic" src=<?php echo $row["address"];?> controls width="100%" height="100%"></music>
                </div>
                </div>
                <div class="theme-popover-mask"></div>
                <!-- <!—点击标题显示新窗口中的视频结束--> -->
                <!--显示总评分-->
                <ul class="list-inline row text-center">
                <?php
                $sqls="select avg(score) from levels where mid=$mid";
                $query=mysql_query($sqls) or die('查询 4失败！'.mysql_error());
                while($row1=mysql_fetch_array($query))
                {
                $number= $row1['0'];
                $p= stripos($number, '.');
                //echo substr($number,0,$p+2);
                if($number==0)
                    echo" <li><h4>影片评分：暂无评分</h4></li>";
                else
                echo" <li><h4>影片评分：</h4></li>".substr($number,0,$p+2);
                }
                ?>
                </ul>
                <!--显示总评分结束-->
                </div>





                <!-- （2）显示视频专栏名称，上传时间，点击次数，上传人，下载次数，有事找
                站长下载地址和评分功能的核心代码如下： -->
                <div class="col-md-8 text-center">
                <table class="table">
                <tr>
                <td>专栏</td>
                <td><?php
                $tid=$row["tid"];
                $sqlt="select * from musictype where tid=$tid";
                $result=mysql_query($sqlt) or die('查询 5失败！'.mysql_error());
                $vname=mysql_fetch_assoc($result);
                echo $vname["typename"];
                ?>
                </td>
                </tr>
                <tr>
                <td>上传时间</td>
                <td><?php
                echo $row["uploaddate"];
                ?>
                </td>
                </tr>
                <tr>
                <td>点击次数</td>
                <td><?php
                echo $row["hittimes"];;
                ?>
                </td>
                </tr>
                <tr>
                <td>上传人</td>
                <td>
                <?php
                $adminid=$row["uploadadmin"];
                $adminrs=mysql_query("select * from admins where adminid=$adminid");
                $admin=mysql_fetch_assoc($adminrs);
                echo $admin["adminname"];
                ?>
                </td>
                </tr>
                <tr>
                <td>下载次数</td>
                <td> <?php
                echo $row["downtimes"];
                ?>
                </td>
                </tr>
                <tr>
                <td>有事找站长</td>
                <td><a href="mailto:zhouhaibo@neusoft.edu.cn">意见箱</a>
                </td>
                </tr>
                <tr>
                <td>下载地址</td>
                <td> <a href="down.php?mid=<?php
                echo $row["mid"];?>" >点击这里下载</a> 
                </td>
                </tr>
                <tr>
                <td>评分</td>
                <td>
                <?php
                //登录后的用户才可以评分
                if(isset($_SESSION["user"]))
                {
                ?>
                <form name="f1" method="get" action="doLevel.php" onsubmit="check()"
                class="form-horizontal">
                <input type="hidden"name="mid" value="<?php
                echo $row["mid"];
                ?>">
                <select name="level" required>
                <option selected value="">评价影片</option>
                <option value="5">力推★★★★★</option>
                <option value="4">推荐★★★★</option>
                <option value="3">还行★★★</option>
                <option value="2">较差★★</option>
                <option value="1">很差★</option>
                </select>
                <input type="submit" value="评价">
                </form>
                <?php
                }else{
                ?>
                <h3 ><a href="#" data-toggle="modal" data-target="#login"
                onclick="func(<?php
                echo $row['mid']
                ?>)">登录</a>后可以评分</h3>
                <?php
                }
                ?>
                </td>
                </tr>
                </table>
                </div>


            </div>
            <!--/row-->
            <div class="row box">

            <!-- （3）显示视频内容简介的核心代码如下： -->
            <div class="col-lg-12">
            <h3 class="intro-text text-center">内容简介</h3>
            <?php
            echo $row["intro"];
            ?>
            </div>


            </div>


            <div class="row box">

            <!-- （3）显示视频内容简介的核心代码如下： -->
            <div class="col-lg-12">
            
            <!-- （4）分页显示留言列表的核心代码： -->
            <?php
            //如果有留言显示留言列表
            $num=mysql_num_rows($result0);
            if($num>0)
            {
            ?>
            <div class="row box">
            <div class="col-md-12">
            <h3 class="intro-text text-center">留言列表</h3>
            <table class="table" align="center">
            <tr>
            <th>序号</th>
            <th>内容</th>
            <th>评论人</th>
            <th>发表时间</th>
            </tr>
            <?php
            $i=1;
            while($row=mysql_fetch_assoc($result0))
            {
            ?>
            <tr>
            <td width="10%"><?php
            echo $i++;
            ?>
            </td>
            <td width="50%"><?php
            echo $row["content"];
            ?>
            </td>
            <td width="20%"><?php
            $uid=$row["uid"];
            $userrs=mysql_query("select * from users where uid=$uid");
            $user=mysql_fetch_assoc($userrs);
            echo $user["uname"];
            ?>
            </td>
            <td width="20%"><?php
            echo $row["cdate"];
            ?>
            </td>
            </tr>
            <?php
            }//end of while
            ?>
            </table>
            <div align="center">
            <?php
            //计算总页数。如果每页显示的行数>总行数，则只有 1页，否则，页数=总行数/每页行数，上取整
            if($rowsperpage >= $totalrows)
            $totalpages = 1;
            else{
            $totalpages = ceil($totalrows / $rowsperpage);
            }
            //如果不是第 1页，则显示第一页和上一页的超链接，否则只显示文字
            if($page>1){
            $first = "<a href=show.php?page=1&mid=$mid>首页</a>";
            $pre = "<a href=show.php?mid=$mid&page=".($page-1).">上一页</a>"; 
            }else{
            $first = '首页';
            $pre = '上一页';
            }
            //如果不是最后一页，则显示下一页和最后一页的超链接，否则只显示文字
            if($page<$totalpages){
            $last = "<a href=show.php?mid=$mid&page=$totalpages>尾页</a>";
            $next = "<a href=show.php?mid=$mid&page=".($page+1).">下一页</a>";
            }else{
            $last = '尾页';
            $next = '下一页';
            }
            //输出分页
            echo "共{$totalrows}条记录&nbsp;&nbsp;";
            echo "$first"."&nbsp;&nbsp;";
            echo "$pre"."&nbsp;&nbsp;";
            for($i=1;$i<=$totalpages;$i++)
            echo "<a href=show.php?mid=$mid&page=$i>第{$i}页</a>&nbsp;&nbsp;";
            echo "$next"."&nbsp;&nbsp;";
            echo "$last";
            ?>
            </div>
            </div>
            </div>
            <?php
            }//end of if
            else{
            ?>
            <div class="row box">
            <div class="col-md-12">
            <h3 class="intro-text text-center">暂无留言</h3>
            </div>
            </div>
            <?php
            }
            ?>
            </div>


            </div>




            <div class="row box">

            <!-- （3）显示视频内容简介的核心代码如下： -->
            <div class="col-lg-12">
            
            <!-- （5）用户发表留言功能的核心代码如下： -->
            <?php
            session_start();
            if(isset($_SESSION["user"]))
            {
            ?>
            <div class="row box">
            <div class="col-md-12">
            <h3 class="intro-text text-center">您的留言</h3>
            <form method="post" action="doComment.php" class="form-horizontal">
            <input type="hidden" name="mid" value=<?php echo $mid ?>>
            <div class="form-group">
            <div class="col-md-12">
            <textarea class="form-control" cols="80" rows="10"   required name="content"></textarea>
            </div>
            </div>
            <div class="form-group">
            <div class="col-md-12 text-center">
            <input type="submit" class="btn btn-default" value="发表留言">
            </div>
            </div>
            </form>
            </div>
            </div>
            <?php
            }else{
            ?>
            <div class="row box">
            <div class="col-lg-12" style="align:center;">
            <h3 ><a href="#" data-toggle="modal" data-target="#login"
            echo $row['mid']
            onclick="func(<?php
            ?>)">登录</a>后可以发表留言</h3>
             
            </div>
            </div>
            <?php
            }
            ?>
            </div>


            </div>





        </div>
        <!--/.col-xs-12.col-sm-12-->

       
    </div>
    <!--/row-->

    

</div>
<!--/.container-->
<hr>

    <footer>
        <p>&copy; Company 2014</p>
    </footer>

<!-- Bootstrap core JavaScript
================================================== -->
<!-- Placed at the end of the document so the pages load faster -->
<script src="assets/js/jquery.min.js"></script>
<script src="assets/js/bootstrap.min.js"></script>

<!-- IE10 viewport hack for Surface/desktop Windows 8 bug -->
<script src="assets/js/ie10-viewport-bug-workaround.js"></script>

<script src="offcanvas.js"></script>
<!-- Script to Activate the Carousel -->
<script>
    $('.carousel').carousel({
        interval: 3000 //changes the speed
    })
</script>
</body>
</html>
